package com.xwli.business.test;

import com.xwli.business.model.ProcessProductInfoReflectSvcCreateEvsInfo;

import java.lang.reflect.Field;

/**
 * @program: springcloud
 * @description:
 * @author: xwli
 * @create: 2023-02-20 21:15
 **/
public class ReflectTestUtils {

    public static void main(String[] args) {
        testOne();
    }

    private static void testOne(){
        try {
            ProcessProductInfoReflectSvcCreateEvsInfo evsInfo = new ProcessProductInfoReflectSvcCreateEvsInfo()
                    .setName("test")
                    .setCount("1");
            evsInfo.setModifyType(1)
                    .setProdInsId("esadas")
                    .setResourceId("sadasdsa");
            Field activeObjectType = evsInfo.getClass().getDeclaredField("activeObjectType"); //反射获取本类的成员属性
            activeObjectType.setAccessible(true);
            System.out.println(activeObjectType.get(evsInfo));
            Field modifyType = evsInfo.getClass().getSuperclass().getDeclaredField("modifyType"); //反射获取本类的父类的成员属性
            modifyType.setAccessible(true);
            System.out.println(modifyType.get(evsInfo));
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
    }
}
